package com.gexin.controller.system.feedback;

import com.gexin.common.model.ApiResponse;
import com.gexin.core.web.SystemBaseController;
import com.gexin.model.user.Feedback;
import com.jfinal.ext.route.ControllerBind;
import com.jfinal.plugin.activerecord.Page;

/**
 * 意见反馈控制器
 */
@ControllerBind(controllerKey = "/system/feedback", viewPath = "WEB-INF/system/feedback/")
public class FeedbackController extends SystemBaseController {
	public  void index(){
		if(isAjax()){
			String content = getPara("content");
			Page<Feedback> feedbackList = Feedback.dao.findFeedbackList(getpage() , getpageSize(),content);
			renderJson(feedbackList);
			return;
		}
		render("feedback.html");
	}

	/**
	 * 回复反馈
	 */
	public void reply(){
		Feedback feedback = getModel(Feedback.class , "feedback");
		if(feedback.getId()==null){
			fail("请求错误!");
			return;
		}
		feedback.setAdminId(getLoginUserId());
		boolean update = feedback.update();
		renderJson(new ApiResponse(update,update?"回复成功":"回复失败"));

	}
}
